package org.tgcloud.group.web.controller.manager;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.*;
import org.tgcloud.group.core.APPResultMessage;
import org.tgcloud.group.core.custom.Permissions;
import org.tgcloud.group.core.session.Session;
import org.tgcloud.group.service.manager.DepartManageService;
import org.tgcloud.group.web.controller.dto.depart.DepartDTO;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @author: zhy
 * @create: 2023-11-06 10:52
 * @description: 部门管理
 */
@Api(tags = "部门管理相关接口")
@RestController
@RequestMapping("/manager/pc/user")
@EnableAutoConfiguration
public class DepartManageController extends ManageAPPBaseController{

    @Autowired
    private DepartManageService departManageService;


    @Permissions("depart:add")
    @ApiOperation(value = "添加部门")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "departName", value = "departName", required = true, dataType = "string"),
            @ApiImplicitParam(name = "managerUserIds", value = "managerUserIds", required = false, dataType = "string"),
            @ApiImplicitParam(name = "pid", value = "pid", required = false, dataType = "string"),
            @ApiImplicitParam(name = "sort", value = "sort", required = false, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/addDepart", method = RequestMethod.POST)
    public APPResultMessage doAddDepart(@RequestParam String departName,
                                        @RequestParam(required = false) String managerUserIds,
                                        @RequestParam(required = false) Integer pid,
                                        @RequestParam(required = false) Integer sort){
        return departManageService.doAddDepart(departName, managerUserIds, pid, sort);
    }


    @Permissions("depart:view")
    @ApiOperation(value = "部门列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "departName", value = "departName", required = false, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/getDepartList", method = RequestMethod.POST)
    public APPResultMessage<Object, DepartDTO> getDepartList(@RequestParam(required = false) String departName){
        return departManageService.getDepartList(departName);
    }


    @Permissions("depart:update")
    @ApiOperation(value = "修改部门")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "string"),
            @ApiImplicitParam(name = "departName", value = "departName", required = true, dataType = "string"),
            @ApiImplicitParam(name = "managerUserIds", value = "managerUserIds", required = false, dataType = "string"),
            @ApiImplicitParam(name = "pid", value = "pid", required = false, dataType = "string"),
            @ApiImplicitParam(name = "sort", value = "sort", required = false, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/updateDepart", method = RequestMethod.POST)
    public APPResultMessage doUpdateDepart(@RequestParam Integer id,
                                           @RequestParam(required = false) String departName,
                                           @RequestParam(required = false) String managerUserIds,
                                           @RequestParam(required = false) Integer pid,
                                           @RequestParam(required = false) Integer sort){
        return departManageService.doUpdateDepart(id, departName, managerUserIds, pid, sort);
    }


    @Permissions("depart:del")
    @ApiOperation(value = "删除部门")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "string")
    })
    @ResponseBody
    @RequestMapping(value = "/delDepart", method = RequestMethod.POST)
    public APPResultMessage doDelDepart(@RequestParam Integer id){
        return departManageService.doDelDepart(id);
    }

}
